﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace JungleSurvivor
{
    class Hole
    {
        public Vector2 position;
        Texture2D texture;
        public Rectangle area;
        public TimeSpan cooldown = TimeSpan.Zero;

        public void LoadTexture(ContentManager content)
        {
            texture = content.Load<Texture2D>("Graphics/traps/Buraco");
        }

        public void Update(List<Enemy> enemyList, GameTime gameTime)
        {
            if (cooldown.Milliseconds <= 0)
            {
                foreach (Enemy enemy in enemyList)
                {
                    if (area.Intersects(enemy.area))
                    {
                        enemy.health -= 8;
                        cooldown = (TimeSpan.FromSeconds(4));
                    }
                }
            }
            else
            {
              cooldown -= gameTime.ElapsedGameTime;
            }

        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, new Rectangle((int)position.X, (int)position.Y, 64, 64), Color.White);
        }
    }
}
